# _*_ utf-8 _*_

# 列表推导式
"""
[表达式 for 变量 in 列表]

"""
names = ['Bob', 'Tom', 'Jerry', 'alice', 'Wendy', 'Smith']
new_names = [name.lower() for name in names if len(name) > 3]
print(new_names)

multiples = [i for i in range(30) if i % 3 == 0]
print(multiples)

# 字典推导式

"""
基本格式：{key_expr: value_expr for value in collection}
or 
{key_expr: value_expr for value in collection if condition}
"""
listdemo = ['Google', 'Runoob', 'Taobao']
newdict = {key: len(key) for key in listdemo}
print(newdict)
dic = {x: x**2 for x in range(30) if x % 2 == 0}
print(dic)

# 集合推导式
"""
base forms:
{expression for item in Sequence}
or
{expression for item in Sequence if condition}
"""
a = {x*2 for x in 'asdvdwefdadvsdxcxsdf123' if x not in 'abd'}
print(a)

setNew = {i ** 2 for i in (1, 2, 3)}
print(setNew)

# 元组推导式
"""
base forms
(expression for items in Sequence)
or
(expression for items in Sequence if condition)
"""

a = (x for x in range(10))
print(a)  # 返回的是生成器对象
print(tuple(a))  # 使用tuple 函数，可以直接将生成器对象转成元组对象

# python中的运算符
"""
+ - * / % // **

比较运算符：
> < == >= <= !=

赋值运算符
= += -= *= /= //= **= := (海象运算符）python3.8

位运算符
& | ^ ~ << >>

逻辑运算符
and or not

成员运算符
in
not in

身份运算符
is is not
"""
